(module-name <console.scm.action>)
(require <console.scm.console>)

(define (action-init)
	(console.ActionSet:init))
(define (action-update task-id name state)
  (console.ActionSet:update name state))
(define (action-properties properties :: console.ActionProperties l)
  (for-each (lambda (p) (properties:put (car p) (cadr p))) l))
(define (action-add action)
	(console.ActionSet:add action))
(define (action-refresh)
	(console.ActionSet:refresh))
(define (make-action-property)
  (console.ActionProperties))
(define (make-action command name . arg)
  (define-class <aaction> (<console.ConsoleAction>)
  	((*init*
       (properties :: console.ActionProperties))
     (invoke-special <console.ConsoleAction> (this) '*init* properties))
    ((actionPerformed e :: java.awt.event.ActionEvent) :: <void> (send-command command (this) (string-append name " "))))
  (let ((action :: console.ConsoleAction (if (> (length arg) 1) (<aaction> (cadr arg)) (<aaction> (console.ActionProperties)))))
    (action:putValue (javax.swing.AbstractAction:.NAME) (name:toString))
    (if (> (length arg) 0)
      (action:putValue (javax.swing.AbstractAction:.MNEMONIC_KEY) (java.lang.Integer (as <int> (car arg)))))
    (action:putValue "action" action)
    action))
